package main

import (
	"fmt"
	"gocv.io/x/gocv"
	"time"
)

func Detect(t *Task) {
	switch t.TypeId {
	case 1:
		trackFront(t)
	case 2:
		trackSide(t)
	case 3:
		signalDownZone(t)
	case 4:
		signalUpZone(t)
	}
}

//trackFront 交通量正面图分析
func trackFront(t *Task) {
	fmt.Println(t.ReqUrl, "：TrackFront")
}

//trackSide 交通量侧面图分析
func trackSide(t *Task) {
	if img, err := gocv.IMDecode(t.data, 1); err == nil {
		TrackSide(img)
	}

	fmt.Println(t.ReqUrl, "：TrackSide")
}

//signalDownZone 信号台下游区图分析
func signalDownZone(t *Task) {
	fmt.Println(t.ReqUrl, "：SignalDownZone")
	time.Sleep(2 * time.Second)
}

//signalUpZone 信号台上游区图分析
func signalUpZone(t *Task) {
	fmt.Println(t.ReqUrl, "：SignalUpZone")
	time.Sleep(3 * time.Second)
}
